/*
 * @Author: wuzhouhai wzh200x@126.com
 * @Date: 2024-07-12 15:54:10
 * @LastEditors: wuzhouhai wzh200x@126.com
 * @LastEditTime: 2024-08-22 17:25:09
 * @FilePath: \dwys_web\extensions\phoenix-plugin-client\assets\core\net\message\messageHandle\s2cLogin_MessageHandle.ts
 * @Description: 
 */
import * as proto from "../../../../core/protoc/ts/proto.js";
import phoenixIns from "../../../Phoenix";
import { PhoenixEventDefine } from "../../../defines/event.define";
import { Opcode } from "../../../defines/opcode.define";
import { IMessageHandle } from "../../../interface/IMessageHandle";
import messageManager from "../../../managers/message.manager";

export default class S2CLoginHandle implements IMessageHandle{
    handleMessage(msgData: any): void {
        let response = msgData as proto.s2c_login;
        console.log("OnLoginHandle", response);
        if (response.base?.code != 0) {
            phoenixIns.EmitEvent(PhoenixEventDefine.PHOENIX_GAME_LOGIN_FAIL, response);
            return;
        }
        phoenixIns.EmitEvent(PhoenixEventDefine.PHOENIX_GAME_LOGIN_SUCCESS, response);
    }
}

messageManager.registerHandle(Opcode.Opcode_SC_LOGIN, new S2CLoginHandle());